<template>
	<view>
		<nav-bar fontColor="#FFFFFF" title="死亡登记"></nav-bar>
		
		
		<uni-section title=" 输入数据" type="line">
			<view class="example">
				<!-- 基础用法，不包含校验规则 -->
				<uni-forms ref="baseForm" :model="baseFormData" labelWidth="80px" labelPosition="left">
					<uni-forms-item required label="请扫耳标">
						<uni-easyinput v-model="baseFormData.ids" placeholder="请输入羊身份编号" />
					</uni-forms-item>
					<!-- <uni-forms-item required label="交配种羊">
						<view style="display: flex;">
							<uni-easyinput v-model="baseFormData.contractNo" placeholder="请输入交配种羊编号" />
							<view @click="chooseOrder"
								style="padding: 20rpx;font-size: 28rpx;color: #0055ff;letter-spacing: 3rpx;font-weight: bold;">
								选择</view>
						</view>
					</uni-forms-item> -->
			
					<uni-forms-item required label="死亡日期">
						<uni-datetime-picker v-model="baseFormData.deadTime"
							placeholder="请选择死亡日期"></uni-datetime-picker>
					</uni-forms-item>
					<!-- <uni-forms-item required label="死亡">
						<!-- <uni-easyinput v-model="addSheepFormData.sex" placeholder="请输入融资单号" /> 
						<uni-data-select  :localdata="deadList" v-model="baseFormData.deadType" placeholder="疫苗种类">
						</uni-data-select>
					</uni-forms-item> -->
					<!-- <uni-forms-item required label="发票">
						<uni-easyinput v-model="baseFormData.invoiceNo" placeholder="请输入发票" />
					</uni-forms-item>
					<uni-forms-item required label="备注">
						<uni-easyinput type="textarea" v-model="baseFormData.remark" placeholder="备注" />
					</uni-forms-item> -->
				</uni-forms>
			</view>
		</uni-section>
		<view style="height: 100rpx;">
			<view class="bottomBox">
				<view class="buttonBox">
					<button class="button_fix" @click="submit" size="default">提交</button>
				</view>
			</view>
		</view>
		<!-- <uni-popup ref="inputDialog" type="dialog">
			<uni-popup-dialog :dataList="salesOrderItemList" title="订单选择" ref="inputClose"
				@confirm="salesOrderItemConfirm" mode="chooseOrder">
			</uni-popup-dialog>
		</uni-popup -->>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				baseFormData: {
					ids:[],
					sheepNo: '', //yang编号
					deadType: '',
					deadTime: ''
				},
			
				active1: 0,
				list1: [{
					title: '填写表单'
				}, {
					title: '完成'
				}],
				vacineeList: [],
				customerSearchList: [],
				salesOrderItemList: [],
				finLoanProductList: []
			}
		},
		onLoad(e) {
			
			this.baseFormData.ids = e.sheepId.split(",")
		/* 	this.supplierSearch(); //收款企业
			this.finLoanProductSearch(); //融资产品
			this.getMyCustInfor(); //获取个人额度
			this.salesOrderItemSearch(); //订单或合同编号 */
		},
		methods: {
			chooseOrder(){
				this.$refs.inputDialog.open();
			},
			salesOrderItemConfirm(e) {
				console.log(e)
				this.baseFormData.contractNo = e[0].contractNo
				this.baseFormData.amount = e[0].custRelSalesPrice
				this.baseFormData.productName = e[0].skuName
				//    this.form.productNo =contract.custSkuId
				this.baseFormData.unit = e[0].unit
				this.baseFormData.qty = e[0].qty
				this.baseFormData.basicNo = e[0].id
				this.baseFormData.salerNo = e[0].supplierNo
			},
			supplierSearch() {
				let opt = {
					url: 'basic/supplier/search',
					method: 'POST'
				};
				this.$http.httpTokenRequest(opt, {}).then(res => {
					for(let i in res.data.data){
						this.supplierList.push({
							text: res.data.data[i].supplierName,
							value: res.data.data[i].id
						})
					}
				})

			},
			supplierChange(e){
				for(let i in this.supplierList){
					if(e == this.supplierList[i].id){
						this.baseFormData.supplierName = this.supplierList[i].supplierName
					}
				}
			},
			finLoanProductSearch() {
				let opt = {
					url: 'loanProduct/finLoanProduct/search',
					method: 'POST'
				};
				this.$http.httpTokenRequest(opt, {}).then(res => {
					for(let i in res.data.data){
						this.finLoanProductList.push({
							text: res.data.data[i].productName,
							value: res.data.data[i].id
						})
					}
				})
			},
			finLoanProductChange(e){
				let opt = {
					url:'loanProduct/finLoanProduct/'+ e,
					method:'GET'
				};
				this.$http.httpTokenRequest(opt).then(res =>{
					this.baseFormData.interestRate= res.data.data.montlyRate
					 this.baseFormData.paymentTimes= res.data.data.paybackNumbers
					this.baseFormData.paymentType= res.data.data.paymentType
				})
			},
			getMyCustInfor() {
				let that = this;
				let opt = {
					url: 'basic/customer/getMyCustInfor',
					method: 'POST'
				};
				this.$http.httpTokenRequest(opt, {}).then(res => {
					that.creditInfor.custType = res.data.data.custType
					that.creditInfor.creditLeft = res.data.data.creditLeft
					that.creditInfor.credit = res.data.data.credit
					that.creditInfor.frezeCredit = res.data.data.frezeCredit
					that.baseFormData.receiverName = res.data.data.customerName
					that.baseFormData.creditBillNo = res.data.data.remark
					that.baseFormData.baoliCompany = res.data.data.baoliCompanyName
				})
			},
			salesOrderItemSearch() {
				let opt = {
					url: 'order/salesOrderItem/search',
					method: 'POST'
				};
				this.$http.httpTokenRequest(opt, {}).then(res => {
					this.salesOrderItemList = res.data.data
				})
			},
			submit(){
				let opt = {
					url:'basic/gzyyDeadReg',
					method:'POST'
				};
				this.baseFormData.deadType = '屠宰'
				this.$http.httpTokenRequest(opt,this.baseFormData).then(res => {
					if(res.data.code == 200){
						uni.showToast({
							title: res.data.msg,
							icon: 'success',
							duration: 1500
						});
						setTimeout(()=>{
							uni.navigateBack({
								delta: 1
							})
						},1500)
					}
					else{
						uni.showToast({
							title: res.data.msg,
							icon: 'error',
							duration: 1500
						});
					}
				})
			}
		}
	}
</script>

<style>
	page {
		background: #f4f4f4;
	}

	.topStep {
		width: 100%;
		/* height: 300rpx; */
		background: #fff;
	}

	.centerBoxtitle {
		font-size: 35rpx;
		color: #000000;
		font-weight: bold;
		margin: 28rpx;

	}

	.numberBox {
		height: 170rpx;
		width: 220rpx;
		text-align: center;
	}

	.numBox {
		/* display: flex; */
		margin-top: 40rpx;
		text-align: center;
	}

	.colorBar {
		height: 40rpx;
		width: 3rpx;
		background: #9d9d9d;
		margin-top: 60rpx;
	}

	.example {
		padding: 20rpx;
		background: #fff;
	}

	.bottomBox {
		position: fixed;
		width: 100%;
		bottom: 20rpx;
		/* margin-bottom: 20rpx; */
		/* z-index: 1000; */
	}

	.buttonBox {
		width: 100%;
		margin: 0 auto;
		display: flex;
		justify-content: space-around;

		// margin-top: 200rpx;
	}

	.button_fix {
		width: 90%;
		height: 70rpx;
		// margin: 0 auto;
		color: #FFFFFF;
		background: #2749C8;
		font-weight: bold;
		letter-spacing: 5rpx;
		font-size: 28rpx;
		line-height: 70rpx;
	}
</style>